home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 316 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: rain.fr!world-net!usenet
  2. From: Martin Kerharo <kerharo@worldnet.fr>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Question about destructor...
  5. Date: 3 Jan 1996 18:38:01 GMT
  6. Organization: World-Net information exchange, Internet provider.
  7. Message-ID: <4ceie9$jmi@aldebaran.sct.fr>
  8. References: <4ce9mk$atg@eng_ser1.erg.cuhk.hk>
  9. NNTP-Posting-Host: client108.sct.fr
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.1N (Macintosh; I; 68K)
  14. X-URL: news:4ce9mk$atg@eng_ser1.erg.cuhk.hk
  15.  
  16. You ask :
  17. >So what should be written in the destructor of B so
  18. >that all the private members inherited from A are also "deleted"?
  19.  
  20. You don't need to do anything : the destructor for "A" will be
  21. automatically called after the destructor for "B" has been called.
  22.  
  23. It's the reversed system that is used for instance initialization :
  24. when you create an object, all its constructors are called, in your
  25. case the constructor for "A" being called before the destructor for
  26. "B", because "B" is derived from "A".
  27.  
  28. When you destroy an object, all destructors are called, in the reverse
  29. order (destructor for "B" first, then destructor for "A").
  30.  
  31. (At least I know the answer to one question ! I hope I didn't make any
  32. mistake...)
  33.  
  34. --Martin
  35.  
  36.  
  37.